package com.egobuy.product.listener;

import com.egobuy.product.mapper.ItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/**
 * @author Hello
 */
@Component
public class ServletContextInitListener implements ServletContextListener {
    @Autowired
    private ItemMapper itemMapper;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        long maxId=itemMapper.getMaxId();
        redisTemplate.opsForValue().set("itemId",maxId+"");

        System.out.println("maxId"+maxId);
    }
}
